//
//  SYUser.swift
//  SingWeibo
//
//  Created by shiying on 15/12/20.
//  Copyright © 2015年 shiying. All rights reserved.
//

import UIKit

class SYUser: NSObject {
    //MARK: - 属性
   
    /// 用户UID
    var id: Int64 = 0
    
    /// 用户昵称
    var screen_name: String?
    
    /// 用户头像地址
    var profile_image_url: String?
    
    /// 认证类型，没有认证 ： -1 认证用户0  企业:2.3.5 达人:220  // 怕以后调用次数频繁，直接就在模型里面将最终的结果传出去
    var verfied_type: Int = -1 {
        didSet {
            switch verfied_type{
                
            case 0:
                verifiedImage = UIImage(named: "avatar_vip")
            case 2, 3, 5:
                verifiedImage = UIImage(named: "avatar_enterprise_vip")
            case 220:
                verifiedImage = UIImage(named: "avatar_grassroot")
            default:
                verifiedImage = nil
            }
        }
    }
    var verifiedImage: UIImage?
    
    /// 会员等级
    var mbrank: Int = 0 {
        didSet {
            if mbrank > 0 && mbrank >= 6 {
                mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            } else {
                mbrankImage = nil
            }
        }
    }
    var mbrankImage: UIImage?
    /// KVO
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override var description: String {
        let prop = ["id", "screen_name", "profile_image_url", "verfied_type", "mbrank"]
        let dict = dictionaryWithValuesForKeys(prop)
        return "\n\t 用户模型\(dict)"
    
    }
    
}
